package com.study.d025paint;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.Paint;
import javafx.scene.paint.RadialGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

/**
*@description 径向渐变
*@author xtayhame
*date 2020年3月21日
*version
*since v1.0
*/
public class RadiaGradientMain extends Application{
	public static void main(String[] args) {
		launch(args);
	}
	@Override
	public void start(Stage stage) throws Exception {
		AnchorPane  anchorPane = new AnchorPane();
		VBox vBox = new VBox(20);

		//HBox hBox1 = new HBox(10);

		GridPane  gridPane = new GridPane();
		gridPane.setVgap(1);
		gridPane.setHgap(8);

		for(int i=0;i<1;i++){
			for(int k=0;k<8;k++){
				Rectangle r1 = new Rectangle(100,100,Color.GRAY);
				gridPane.add(r1, k, i);
			}
		}

		//hBox1.getChildren().add(gridPane);


		HBox hBox2 = new HBox(10);
		hBox2.getChildren().add(new Circle(60, Color.BLACK));
		hBox2.getChildren().add(new Circle(60, Color.BLACK));
		hBox2.getChildren().add(new Circle(60, Color.BLACK));
		hBox2.getChildren().add(new Circle(60, Color.BLACK));
		hBox2.getChildren().add(new Polygon(100,0,200,200,0,200));



		vBox.getChildren().addAll(gridPane,hBox2);
		anchorPane.getChildren().add(vBox);
		stage.setScene(new Scene(anchorPane, 900, 500));
		stage.show();

		Stop[] stops1 = new Stop[]{
				new Stop(0, Color.valueOf("#FFDEAD")),
				new Stop(0.5, Color.valueOf("#8B3626")),
				new Stop(1, Color.valueOf("#171717")),

		};
		//在左上角
		RadialGradient  r1 = new RadialGradient(0, 0, 0, 0, 100, false, CycleMethod.NO_CYCLE, stops1);
		Rectangle rectangle1 =(Rectangle)gridPane.getChildren().get(0);
		rectangle1.setFill(r1);

		//在正中间
		RadialGradient  r2 = new RadialGradient(0, 0, 50, 50, 50, false, CycleMethod.NO_CYCLE, stops1);
		Rectangle rectangle2 =(Rectangle)gridPane.getChildren().get(1);
		rectangle2.setFill(r2);

		//焦点向左移动50
		RadialGradient  r3 = new RadialGradient(0, -50, 50, 50, 50, false, CycleMethod.NO_CYCLE, stops1);
		Rectangle rectangle3 =(Rectangle)gridPane.getChildren().get(2);
		rectangle3.setFill(r3);

		//焦点向左移动50 ， 且顺时转动45°
		RadialGradient  r4 = new RadialGradient(45, -50, 50, 50, 50, false, CycleMethod.NO_CYCLE, stops1);
		Rectangle rectangle4 =(Rectangle)gridPane.getChildren().get(3);
		rectangle4.setFill(r4);

		//焦点向左移动50 ， 且顺时转动45°
		RadialGradient  r5 = new RadialGradient(45, -50, 50, 50, 25, false, CycleMethod.REPEAT, stops1);
		Rectangle rectangle5 =(Rectangle)gridPane.getChildren().get(4);
		rectangle5.setFill(r5);


		//焦点向左移动50 ， 且顺时转动45°
				RadialGradient  r6 = new RadialGradient(45, 1, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE, stops1);
				Rectangle rectangle6 =(Rectangle)gridPane.getChildren().get(5);
				rectangle6.setFill(r6);

				RadialGradient  r7 = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, stops1);
				Circle c1 =(Circle)hBox2.getChildren().get(0);
				c1.setFill(r7);

				RadialGradient  r8 = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE, stops1);
				Circle c2 =(Circle)hBox2.getChildren().get(1);
				c2.setFill(r8);

				RadialGradient  r9 = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.REFLECT, stops1);
				Circle c3 =(Circle)hBox2.getChildren().get(2);
				c3.setFill(r9);

				RadialGradient  r10 = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.REFLECT, stops1);
				Polygon  pg1 =(Polygon)hBox2.getChildren().get(4);
				pg1.setFill(r10);

	}
}
